/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package data;

import java.io.Serializable;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author jzajaczek
 */ 

@ManagedBean(name="dbconnectBean")
@SessionScoped

public class dbconnectBean implements Serializable {
    private ResultSet ResultSet;
    
    public Connection dbConnection() throws ClassNotFoundException {
        Connection con = null;
        
        String dbUrl = "jdbc:mysql://localhost:3306/db_calculation";
        String dbClass = "com.mysql.jdbc.Driver";
        
        try {
           Class.forName("com.mysql.jdbc.Driver").newInstance();
           con = DriverManager.getConnection(dbUrl, "root", "anuluj");
           
           if(!con.isClosed())
               System.out.println("OK");
            
        } catch (Exception ex) {
            System.err.println("dupa: " + ex.getMessage());
        }
        return con;
    }  
}